package cn.tedu.kcircle.passport.adapter.converter;

import cn.tedu.kcircle.passport.adapter.vo.UserLoginResultVO;
import cn.tedu.kcircle.passport.protocol.dto.UserInfoDTO;
import cn.tedu.kcircle.passport.protocol.param.UserRegisterParam;
import cn.tedu.kcircle.passport.repository.model.UserLoginInfoModel;
import cn.tedu.kcircle.passport.repository.model.UserRegisterModel;
import cn.tedu.kcircle.passport.service.bo.UserLoginInfoBO;
import cn.tedu.kcircle.passport.service.bo.UserLoginResultBO;
import cn.tedu.kcircle.passport.service.bo.UserStateBO;
import lombok.val;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
public class PassportAdapterConverter {
    public UserLoginResultVO BO2VO(UserLoginResultBO userLoginResultBO){
        UserLoginResultVO userLoginResultVO = new UserLoginResultVO();
        BeanUtils.copyProperties(userLoginResultBO,userLoginResultVO);
        if(userLoginResultVO.getPermission()==null){
            userLoginResultVO.setPermission(new ArrayList<>());
        }
        return userLoginResultVO;
    }
    public UserLoginInfoBO model2BO(UserLoginInfoModel userLoginInfoModel){
        UserLoginInfoBO userLoginInfoBO = new UserLoginInfoBO();
        BeanUtils.copyProperties(userLoginInfoModel,userLoginInfoBO);
        return userLoginInfoBO;
    }
    public UserRegisterModel param2Model(UserRegisterParam userRegisterParam){
        UserRegisterModel userRegisterModel = new UserRegisterModel();
        BeanUtils.copyProperties(userRegisterParam,userRegisterModel);
        return userRegisterModel;
    }
    public UserInfoDTO bo2DTO(UserStateBO userStateBO){
        UserInfoDTO userInfoDTO = new UserInfoDTO();
        BeanUtils.copyProperties(userStateBO,userInfoDTO);
        return userInfoDTO;
    }
}
